package cn.cau.epidemicsurveysystem.control;

import cn.cau.epidemicsurveysystem.bean.StaffInfoBean;
import cn.cau.epidemicsurveysystem.service.StaffInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @projectName: gp2022
 * @package: cn.cau.epidemicsurveysystem.control
 * @className: StaffManageController
 * @author: zfy
 * @description: 人员管理有关页面跳转及数据处理
 * @date: 2022/3/3 0003 8:48
 * @version: 1.0
 */

@Controller
public class StaffManageController {
    @Autowired
    StaffInfoService staffInfoService;

    /**
     * @param :
     * @return ModelAndView
     * @author zfy
     * @description  流调人员列表
     * @date 2022/3/3 9:45
     */
    @RequestMapping(value = "/staffList")
    public ModelAndView staffList(){
        ModelAndView modelAndView=new ModelAndView();
        List<StaffInfoBean> staffInfoBeans=staffInfoService.findall();
        modelAndView.addObject("staffInfoBeans",staffInfoBeans);
        modelAndView.setViewName("epid_contacts");
        return modelAndView;
    }

    /**
     * @param :staffId
     * @return ModelAndView
     * @author zfy
     * @description  流调人员信息详情
     * @date 2022/3/3 14:00
     */
    @RequestMapping(value = "/staffInfoDetails")
    public ModelAndView staffInfoDetails(@RequestParam("staffId") int staffId){
        ModelAndView modelAndView=new ModelAndView();
//        根据id查找人员
        StaffInfoBean staffInfoBean=staffInfoService.findStaffById(staffId);
        modelAndView.addObject("staffInfoBean",staffInfoBean);
        modelAndView.setViewName("epid_profile");
        return modelAndView;
    }

}
